package org.example.Context;

import java.util.concurrent.TimeUnit;

public class QueryFromHttpAction implements QueryAction{
    @Override
    public void execute() {
        try {
            TimeUnit.MILLISECONDS.sleep(500);
            String id  = ActionContext.getActionContext().getContext().getId();
            ActionContext.getActionContext().getContext().setName(this.getNameById(id));

        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    private String getNameById(String id){
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        return "bjsxt" + Thread.currentThread().getName();
    }
}
